package com.market.pay;

import com.market.entity.base.Fruit;
import com.market.entity.dto.OrderDto;
import com.market.pay.base.PricingStrategy;
import com.market.pay.details.BasePricingStrategy;
import com.market.pay.details.FullReductionStrategy;
import com.market.pay.details.StrawberryDiscountStrategy;

import java.math.BigDecimal;

public class MarketCalculator {
    // 顾客A: 苹果和草莓（无折扣）
    public static BigDecimal calculateCustomerA(int appleKg, int strawberryKg) {
        OrderDto orderDto = new OrderDto(null);
        orderDto.addItem(Fruit.APPLE, new BigDecimal(appleKg));
        orderDto.addItem(Fruit.STRAWBERRY, new BigDecimal(strawberryKg));
        return new BasePricingStrategy().calculateTotal(orderDto);
    }

    // 顾客B: 苹果、草莓、芒果（无折扣）
    public static BigDecimal calculateCustomerB(int appleKg, int strawberryKg, int mangoKg) {
        OrderDto orderDto = new OrderDto(null);
        orderDto.addItem(Fruit.APPLE, new BigDecimal(appleKg));
        orderDto.addItem(Fruit.STRAWBERRY, new BigDecimal(strawberryKg));
        orderDto.addItem(Fruit.MANGO, new BigDecimal(mangoKg));
        return new BasePricingStrategy().calculateTotal(orderDto);
    }

    // 顾客C: 草莓打8折
    public static BigDecimal calculateCustomerC(int appleKg, int strawberryKg, int mangoKg) {
        OrderDto orderDto = new OrderDto();
        orderDto.addItem(Fruit.APPLE, new BigDecimal(appleKg));
        orderDto.addItem(Fruit.STRAWBERRY, new BigDecimal(strawberryKg));
        orderDto.addItem(Fruit.MANGO, new BigDecimal(mangoKg));
        PricingStrategy strategy = new StrawberryDiscountStrategy(new BasePricingStrategy());
        return strategy.calculateTotal(orderDto);
    }

    // 顾客D: 草莓8折 + 满100减10
    public static BigDecimal calculateCustomerD(int appleKg, int strawberryKg, int mangoKg) {
        OrderDto orderDto = new OrderDto();
        orderDto.addItem(Fruit.APPLE, new BigDecimal(appleKg));
        orderDto.addItem(Fruit.STRAWBERRY, new BigDecimal(strawberryKg));
        orderDto.addItem(Fruit.MANGO, new BigDecimal(mangoKg));
        PricingStrategy strategy = new FullReductionStrategy(
                new StrawberryDiscountStrategy(new BasePricingStrategy())
        );
        return strategy.calculateTotal(orderDto);
    }
}
